package cn.iocoder.yudao.module.student.controller.app.invite;

import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.member.api.interviewInvite.InterviewInviteApi;
import cn.iocoder.yudao.module.member.api.interviewInvite.dto.InterviewInviteReqDTO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.annotations.*;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.student.controller.app.invite.vo.*;
import cn.iocoder.yudao.module.student.dal.dataobject.invite.InviteDO;
import cn.iocoder.yudao.module.student.convert.invite.InviteConvert;
import cn.iocoder.yudao.module.student.service.invite.InviteService;

@Api(tags = "用户 APP - 面试邀约")
@RestController
@RequestMapping("/student/invite")
@Validated
public class AppInviteController {

    @Resource
    private InviteService inviteService;
    @Resource
    private InterviewInviteApi interviewInviteApi;
    @PutMapping("/update")
    @ApiOperation("更新面试邀约")
    public CommonResult<Boolean> updateInvite(@Valid @RequestBody AppInviteUpdateReqVO updateReqVO) {
        inviteService.updateInvite(updateReqVO);
        return success(true);
    }


    @GetMapping("/get")
    @ApiOperation("获得面试邀约")
    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
    public CommonResult<AppInviteRespVO> getInvite(@RequestParam("id") Long id) {
        InviteDO invite = inviteService.getInvite(id);
        return success(InviteConvert.INSTANCE.convert(invite));
    }


    @PostMapping("/page")
    @ApiOperation("获得面试邀约分页")
    public CommonResult<PageResult<AppInviteRespVO>> getInvitePage(@Valid @RequestBody AppInvitePageReqVO pageVO) {
        return success(inviteService.getInvitePage(pageVO));
    }


    @PostMapping("/invitedFeedback")
    @ApiOperation("获得面试邀约反馈")
    @TenantIgnore
    public CommonResult<PageResult<AppInviteRespVO>> invitedFeedback(@Valid AppInvitePageReqVO pageVO) {
        return success(inviteService.invitedFeedback(pageVO));
    }


    @GetMapping("/noOpenInvitationRecordCount")
    @ApiOperation("获得面试邀约未读取数量")
    @TenantIgnore
    public CommonResult<Long> noOpenInvitationRecordCount(@Valid InterviewInviteReqDTO reqDTO) {
        return success(interviewInviteApi.resultNoOpenCount(reqDTO));
    }

    @GetMapping("/isOpenInvitationRecordCount")
    @ApiOperation("获得面试反馈未数量")
    @TenantIgnore
    public CommonResult<Long> isOpenInvitationRecordCount(@Valid InterviewInviteReqDTO reqDTO) {
        return success(interviewInviteApi.resultIsOpenCount(reqDTO));
    }
}
